package routers

import (
    "backend/controllers"
    beego "github.com/beego/beego/v2/server/web"
)

func init() {

	// 首页&分类&详情
	beego.Router("/", &controllers.HomeController{}, "get:Index")                // 首页
	beego.Router("/explore", &controllers.ExploreController{}, "get:Index")     // 分类
	beego.Router("/books/:key", &controllers.DocumentController{}, "get:Index") // 图书目录,详情

	//// 读书
	beego.Router("/read/:key/:id", &controllers.DocumentController{}, "*:Read")         // 图书目录&详情
	beego.Router("/read/:key/search", &controllers.DocumentController{}, "post:Search") // 图书章节内容搜索

	// 图书编辑
	beego.Router("/api/:key/content/?:id", &controllers.DocumentController{}, "*:Content") // 保存文档
	beego.Router("/api/:key/edit/?:id", &controllers.DocumentController{}, "*:Edit")       // 编辑文档
	beego.Router("/api/upload", &controllers.DocumentController{}, "post:Upload")          // 上传图片
	beego.Router("/api/:key/create", &controllers.DocumentController{}, "post:Create")     // 上传章节
	beego.Router("/api/:key/delete", &controllers.DocumentController{}, "post:Delete")     // 删除章节

	// 搜索
	beego.Router("/search", &controllers.SearchController{}, "get:Search")      // 搜索
	beego.Router("/search/result", &controllers.SearchController{}, "get:Result") // 搜索结果

	// 登录
	beego.Router("/login", &controllers.AccountController{}, "*:Login")          // 登录
	beego.Router("/regist", &controllers.AccountController{}, "*:Regist")        // 注册
	beego.Router("/logout", &controllers.AccountController{}, "*:Logout")        // 退出
	beego.Router("/doregist", &controllers.AccountController{}, "post:DoRegist") // 注册

	// 用户图书管理
	beego.Router("/book", &controllers.BookController{}, "*:Index")                        // 我的图书页面
	beego.Router("/book/create", &controllers.BookController{}, "post:Create")             // 创建图书
	beego.Router("/book/:key/setting", &controllers.BookController{}, "*:Setting")         // 图书设置
	beego.Router("/book/star/:id", &controllers.BookController{}, "*:Collection")          // 收藏图书
	beego.Router("/book/setting/save", &controllers.BookController{}, "post:SaveBook")     // 保存图书
	beego.Router("/book/:key/release", &controllers.BookController{}, "post:Release")      // 发布图书
	beego.Router("/book/setting/token", &controllers.BookController{}, "post:CreateToken") // 创建Token

	// 个人中心
	beego.Router("/user/:username", &controllers.UserController{}, "get:Index")                 // 个人分享页面
	beego.Router("/user/:username/collection", &controllers.UserController{}, "get:Collection") // 个人收藏页面
	beego.Router("/user/:username/follow", &controllers.UserController{}, "get:Follow")         // 个人关注页面
	beego.Router("/user/:username/fans", &controllers.UserController{}, "get:Fans")             // 个人粉丝页面
	beego.Router("/follow/:uid", &controllers.UserController{}, "get:SetFollow")                // 关注或取消关注
	beego.Router("/book/score/:id", &controllers.BookController{}, "*:Score")                   // 评分
	beego.Router("/book/comment/:id", &controllers.BookController{}, "post:Comment")            // 评论

	// 个人设置
	beego.Router("/setting", &controllers.SettingController{}, "*:Index")  // 个人设置页面
	beego.Router("/setting", &controllers.SettingController{}, "*:Upload") // 上传图片

	// 管理后台
	beego.Router("/manager/category", &controllers.ManagerController{}, "post,get:Category")    // 管理后台页面
	beego.Router("/manager/update-cate", &controllers.ManagerController{}, "get:UpdateCate")    // 更新分类信息
	beego.Router("/manager/del-cate", &controllers.ManagerController{}, "get:DelCate")       // 删除分类信息
	beego.Router("/manager/icon-cate", &controllers.ManagerController{}, "post:UpdateCateIcon") //更新分类信息图标

}
